<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:p="http://primefaces.org/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core">

<ui:composition template="#{diretorios.template}/layout.xhtml">
	<ui:define name="content">
		<div>
			<h:outputText value="Cadastro"
				style="font-size: 18px; color: #eeeeee" />
			<br />
		</div>
		<div>
				<p:panel header="Cadastro de Atrasador"
					style="margin-bottom: 5px; border: hidden; width: 780px;" />
		</div>
		<h:form>
			<p:panel id="panel"
				style="margin-bottom: 5px;">

				<p:messages id="messages" showDetail="false"/>
				
				<div align="center">				
					<p:ajaxStatus>
						<f:facet name="start">
							<p:graphicImage value="/resources/media/ajaxstatus.gif"/>
						</f:facet>
						<f:facet name="complete">
							<h:outputText value=""/>
						</f:facet>
					</p:ajaxStatus>
				</div>
				
				<h:panelGrid columns="3">

					<h:outputText value="Nome:" />
					<p:inputText id="name"
						value="#{cadastroAtrasador.atrasador.idAtrasador.nome}"
						style="width: 300px;" label="Nome" required="true" size="45" />
					
					<h:panelGrid columns="2">
						<h:outputText value="Estado:" />				
						<p:selectOneMenu id="UF" value="#{cadastroAtrasador.UF}" valueChangeListener="#{pegaUFsCidades.actionCombo}" required="true" 
												 label="Estado" style="min-width: 230px">
							<f:selectItem itemLabel="Selecione"/>
							<f:selectItems value="#{pegaUFsCidades.listaUFs}" var="uf"
										   itemLabel="#{uf.nome}"
										   itemValue="#{uf.idUF}" />
							<p:ajax process="@this" event="change" update="cidade"  />								   
						</p:selectOneMenu>
					</h:panelGrid>

					<h:outputText value="Descrição:" />
					<p:inputTextarea value="#{cadastroAtrasador.atrasador.descricao}" required="true" label="Descrição"
									 style="width: 300px;" />
					<h:panelGrid columns="2">
						<h:outputText value="Cidade:"/>
						<p:selectOneMenu id="cidade"  value="#{cadastroAtrasador.atrasador.idAtrasador.codCidade.idCidade}" required="true" 
										 label="Cidade" style="min-width: 230px">
							<f:selectItem itemLabel="Selecione"/>
							<f:selectItems value="#{pegaUFsCidades.listaCidades}" var="cidade"
										   itemLabel="#{cidade.nome}"
										   itemValue="#{cidade.idCidade}" />
						</p:selectOneMenu>
					</h:panelGrid>
				</h:panelGrid>
			</p:panel>
			<p:panel>
				<h:panelGrid columns="3">
					<h:outputText value="E-mail:" />
					<p:inputText id="email" value="#{cadastroAtrasador.atrasador.idAtrasador.email}" label="Email" required="true"
											style="width: 300px;" />
					<p:commandButton id="botao" value="Testar disponibilidade"			
									 actionListener="#{cadastroAtrasador.testaEmailAction}"					 
									 title="Testar Disponibilidade" update="messages" process="email @this">
					</p:commandButton>

					<h:outputText value="Senha:" />
					<p:password id="senha1" value="#{cadastroAtrasador.senha1}" required="true" label="Senha"
								style="width: 240px;" inline="true"
								promptLabel="Por favor, digite a senha!" weakLabel="Fraca!"
								goodLabel="Boa!" strongLabel="Forte!" />
					<h:outputLabel></h:outputLabel>

					<h:outputText value="Confirmar senha:" />
					<p:password id="senha2" value="#{cadastroAtrasador.senha2}" required="true" label="Confirmar senha"
								style="width: 240px;" inline="true"
								promptLabel="Por favor digite a senha" weakLabel="Fraca!"
								goodLabel="Boa!" strongLabel="Forte!" feedback="false"/>
					<h:outputLabel></h:outputLabel>
				</h:panelGrid>
			</p:panel>
			<p:panel>
				<div align="center">
					<p:commandButton value="Cadastrar" action="#{cadastroAtrasador.cadastrar}" ajax="false"/>
				</div>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
</html>